object Demo07ScalaApply {
  def main(args: Array[String]): Unit = {
    // 创建一辆汽车
    val car1: Car = new Car("丰田", "白色")
    println(car1._brand)

    val car2: Car = Car.apply("本田", "黑色")
    println(car2._brand)

    val car3: Car = Car("马自达", "红色")
    println(car3._brand)

  }

}

class Car(brand: String, color: String) {
  val _brand: String = brand
  val _color: String = color
}

// 伴生对象
object Car {
  def apply(brand: String, color: String): Car = new Car(brand, color)
}
